<template>
	<view class="my-cart">
		<view class="tabbar-1"></view>
		<scroll-view class="cart" scroll-y>
			<cart-list :item="checkeds" ref="childMethod" :datas="data" @showChild="receiveMsg"></cart-list>
		</scroll-view>
		<!-- <cart-list></cart-list> -->
		<view class="bottom">
			<view class="a">
				<checkbox-group @change='setcheckeds'>
					<label>
						<checkbox color="#a397fd" style="transform:scale(0.8)" :checked="checkeds">全选</checkbox>
					</label>
				</checkbox-group>
				<view class="sum">
					<text>总价：¥{{pricenum}}</text>
					<button @click="gowhere('/pages/pay02/pay02',data)">结算</button>
				</view>

			</view>
		</view>
	</view>
</template>

<script>
	import {Addmallcartchas} from '@/service/index.js'
	import cartList from '@/components/cart-list/cart-list.vue'
	export default {
		components: {
			cartList
		},
		data() {
			return {
				checkeds: false,
				data:'',
				pricenum:0
			
			}
		},
	async mounted() {
			let res=await Addmallcartchas(this.$uid)
			console.log(res);
			this.data=res.result
		},
		methods: {
			receiveMsg(msg){
				this.pricenum=msg.childName
			},
			setcheckeds() {
				this.checkeds = !this.checkeds
				this.$refs.childMethod.setChecked();
				console.log(this.$refs.childMethod.checked);
				this.pricenum=this.pricenum*(this.$refs.childMethod.checked)
			},

			gowhere(path,res) {
				this.$router.push({
                   path:path,
	               query:res
				})
			},
		}
	}
</script>

<style lang="scss">
	page{
		height:100%;
	}
	.my-cart {
		height:  99%;
		position: relative;
		display: flex;
		.tabbar-1 {
			background-color: #a397fd;
			height: 10%;
			width: 100%;
			position: fixed;
		}
		.cart{
			height: 89%;
			// border: 1px solid red;
			overflow: hidden;
			position: relative;
		}
		.bottom {
			height: 10%;
			padding: 0 10px;
			background-color: #fff;
			width: 700rpx;
			position: absolute;
			bottom:0;

			.a {
				display: flex;
				align-items: center;
				justify-content: space-between;

				.sum {
					// flex: 1;
					display: flex;
					align-items: center;
					justify-content: end;

					text {
						font-size: 14px;
						margin-right: 40rpx;
					}

					button {
						background-color: #a397fd;
						color: white;
						padding: 0 80rpx;
						line-height: 32px;
						font-size: 16px;
						border-radius: 50rpx;
					}
				}

			}
		}
	}
</style>
